package com.fy.market.strategy.model.entity;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author fwq
 * @desc 策略实体
 * @date 2025-09-26
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class StrategyEntity implements Serializable {

    /**
     * 自增ID
     */
    private Integer id;
    /**
     * 策略ID
     */
    private Integer strategyId;
    /**
     * 策略描述
     */
    private String strategyDesc;
    /**
     * 策略规则模型主键
     */
    private String ruleModelIds;
    /**
     * 策略兜底奖品
     */
    private Integer guaranteedAwardId;
    /**
     * 获取策略规则模型id集合（保持顺序）
     * @return
     */
    public List<Integer> getStrategyRuleModelIdList(){
        List<Integer> idList = new ArrayList<>();
        String idsStr = this.getRuleModelIds();
        if (idsStr == null) return idList;
        String[] ids = idsStr.split(",");
        return Arrays.stream(ids).map(Integer::valueOf).collect(Collectors.toList());
    }

    /**
     * 策略规则模型实体集合
     */
    private List<RuleModelEntity> strategyRuleModels;
}
